import { useEffect } from "react"

export default function useScrollPosCustom(setOffsetTop) {
  useEffect(() => {
    window.addEventListener("scroll", function (event) {
      let s = document.documentElement.scrollTop || document.body.scrollTop
      console.log("距离顶部距离:", s)
      setOffsetTop(s)
      if (
        window.pageYOffset + window.innerHeight >=
        document.body.offsetHeight
      ) {
        console.log("到达底部")
      }
    })
    return function willLeave() {
      window.removeEventListener("scroll", () => {})
    }
  })
}
